"""
弹窗模块
实现日期详情弹窗
"""
import tkinter as tk
from tkinter import ttk
from PIL import Image, ImageTk

class DayDetailPopup:
    def __init__(self, master, year, month, day, lunar_date, festival):
        self.top = tk.Toplevel(master)
        self.top.title(f"{year}年{month}月{day}日详情")
        self.top.geometry("400x300")

        # 设置背景
        self.bg_image = Image.open("assets/bg_images/popup_bg.jpg")
        self.bg_photo = ImageTk.PhotoImage(self.bg_image)
        self.bg_label = tk.Label(self.top, image=self.bg_photo)
        self.bg_label.place(x=0, y=0, relwidth=1, relheight=1)

        # 内容框架
        content_frame = tk.Frame(self.top, bg="white", bd=2, relief=tk.GROOVE)
        content_frame.place(relx=0.5, rely=0.5, anchor=tk.CENTER,
                          width=380, height=280)

        # 日期信息
        tk.Label(content_frame, text=f"公历: {year}年{month}月{day}日",
                font=("Arial", 12, "bold"), bg="white").pack(pady=10)

        tk.Label(content_frame, text=f"农历: {lunar_date.chinese()}",
                font=("Arial", 12), bg="white").pack()

        # 节日信息
        if festival:
            tk.Label(content_frame, text=f"节日/节气: {festival}",
                    font=("Arial", 12), fg="red", bg="white").pack(pady=10)

        # 关闭按钮
        close_btn = tk.Button(content_frame, text="关闭",
                            command=self.top.destroy)
        close_btn.pack(pady=20)
